package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Role;
import com.itheima.service.RoleService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author liam
 * @description 角色控制器
 * @date 2020/3/8-15:13
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/role")
public class RoleController {

    @Reference
    private RoleService roleService;

    @RequestMapping("/findAll")
    public Result findAll() {
        List<Role> roles = roleService.findAll();
        return Result.success("",roles);
    }
    /**
    wangqi 3.8查询
    */
    @RequestMapping("/findPage.do")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        return roleService.findPage(queryPageBean);
    }

    /**
     * wangqi 3.8 新增
     * */
    @RequestMapping("/add.do")
    public Result add(@RequestBody Role role){
        roleService.add(role);
        return Result.success("");
    }

    /**
     * wangqi 3.8 编辑
     * */
    @RequestMapping("/findById4Edit")
    public Result findById4Edit(Integer id) {
        Map map = roleService.findById4Edit(id);
        return Result.success("", map);
    }
}
